# Maintainer (Arch) : Felix Yan <felixonmars@archlinux.org>
# Contributor : Brian Bidulock <bidulock@openss7.org>
# Maintainer : Sagar Acharya <sagar@hyperbola.info>

pkgname=http-parser
pkgver=2.9.4
pkgrel=1
pkgdesc="Parser for HTTP Request/Response written in C"
arch=('x86_64')
url="https://github.com/nodejs/http-parser"
license=('Expat')
depends=('glibc')
makedepends=('quilt')
source=($pkgname-$pkgver.tar.gz::"${url}/archive/v$pkgver.tar.gz"
		"series"
		"cherry-pick.v2.9.4-4-g805a0d1.fix-test-numbers.patch"
		"cherry-pick.v2.9.4-6-gd9275da.fix-wsign-compare-warning.patch"
		"cherry-pick.v2.9.4-7-g4b99e42.test-content-length-header-parsing.patch"
		"cherry-pick.v2.9.4-8-ge13b274.allow-content-length-and-transfer-encoding-chunked.patch"
		"cherry-pick.v2.9.4-9-g4f15b7d.fix-sizeof-http-parser-assert.patch")
sha512sums=('b45df7b94d1c51079d44687d0a7f901f44faae51df4e84c7e3fe38f130c2d809d0e7c2a146c57b3723e60732aededc246bf44eadb10a95b710963d641f9fe7cd'
			'a30538ea9add0cb95c5c1b776469b98e6807e41f860d03c58b76529129c7de4a178ce2187500c05ae85d83a7f777a131fd3188ce5a9eb52bdd264e7be3d5c43c'
			'6365c8d88a51d5bcac4d2c775cf3358bab0135a0a268e5f95bc2a3fb2233bdc1bd69cd667312221d63bc7da42efc930cec833151b6fd42545f493455d53bfb71'
			'f3eb9c4addbca349e49de997a9618790b6a3f6bd4974bbcc45d587664de58c1e1248f3ae0d68fce5721e57c1435f94f5651ae3a9d8786f4025a8fb434b136639'
			'73ecafabebabb334f1e99eeb1cd65691ffbbb92c5dfbd5ac50da421574f9a071c79653392629e29724eb80c7029015cad8ff312b1d700d68dba958076357cc54'
			'35c78957489f7ece9580a333f659075e8d1ee3ec1d3a2e0718e308cf98454975540ada27a12c0dc41161a4fca49269365ba65c20107281779bce0afe1c26a1ea'
			'ac6ffc375e7afaf786401ebf865079824249eb3b96ce180a0590f66bf8d537d62d7829e1d28007fe023b6cc72c50d82045c272b4012e127829fb65996d32817f')

prepare() {
	cd $pkgname-$pkgver
	
	mkdir ./patches
  	cp ${srcdir}/series ./patches
  	cp ${srcdir}/*.patch ./patches

  	export QUILT_PATCHES=patches
  	export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
  	export QUILT_DIFF_ARGS='--no-timestamps'

  	quilt push -av
	
	sed -i 's|-Werror||' Makefile
}


build() {
  cd $pkgname-$pkgver
  make library
}

check() {
  cd $pkgname-$pkgver
  make test
}

package() {
  cd $pkgname-$pkgver
  make PREFIX="$pkgdir/usr" install
  install -Dm644 LICENSE-MIT -t "$pkgdir"/usr/share/licenses/$pkgname/
}
